<%@ page import="java.sql.*" %> 
<%@ page import="java.lang.*" %> 
<%@ page import="java.io.*" %> 
<%@ page language="java" import="net.sf.json.JSONArray" %>
<%@ page language="java" import="net.sf.json.JSONObject" %> 
<%
try {
String connectionURL = "jdbc:mysql://webproject2.cse.ust.hk/BookwarmMobile?user=BookwarmMobile&password=bookwarm"; 

Connection connection = null; 

Class.forName("com.mysql.jdbc.Driver").newInstance(); 

connection = DriverManager.getConnection(connectionURL);

if(!connection.isClosed()){
Statement statement = null;
ResultSet rs = null; 
String newUser = null;
String newPassword = null;

newUser = request.getParameter("username");
newPassword = request.getParameter("password");

statement = connection.createStatement();
rs = statement.executeQuery("SELECT * FROM Users WHERE AccountName = '" + newUser + "' AND Password = '" + newPassword + "';");
int count_user = 0;
while (rs.next()) {
	count_user++;
}
statement.close();

if(count_user == 0) {
out.print("no_user_found");

}
else {
out.print("user_logged_in");

}

}

connection.close();

}
catch(Exception ex){
out.print(ex);

}  
%>